package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * Package: com.atguigu.lease.common.minio
 *
 * @Description:
 * @Author xiongkunYang
 * @Create 2025/4/27 16:03
 */
@SpringBootConfiguration
@EnableConfigurationProperties({MinioProperties.class})
public class MinioConfiguration {

    private final MinioProperties minioProperties;

    public MinioConfiguration(MinioProperties minioProperties) {
        this.minioProperties = minioProperties;
    }

    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
                .build();
    }

}